package org.abettor.pushbox.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class PushBoxDbHelper extends SQLiteOpenHelper {
	private static final int DATABASE_VERSION = 1;
	public static final String DATABASE_NAME = "ni_push_box";
	public static final String PUSH_BOX_TABLE_NAME = "push_box_table";
	public static final String PUSH_BOX_ID = "_id";
	public static final String PUSH_BOX_NAME = "name";
	public static final String PUSH_BOX_SOLVED = "issolved";
	public static final String PUSH_BOX_ISDRAFT = "isdraft";
	public static final String PUSH_BOX_TYPE = "type";
	public static final String PUSH_BOX_RESOLVE_FILENAME = "resove_filename";
	public static final String PUSH_BOX_MAP_FILENAME = "map_filename";
	public static final String PUSH_BOX_RESOLVE_TIME = "resolve_time";
	public static final String PUSH_BOX_CREATE_TIME = "create_time";
	public static final String PUSH_BOX_HASUPLOADED = "hasuploaded";
	public static final String PUSH_BOX_UPLOADED_TIME = "uploaded_time";
	public static final String PUSH_BOX_MISSION_ID = "missionid";
	public static final String PUSH_BOX_REMOTE_ID = "remoteid";// 远程的id

	public PushBoxDbHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		String sql1 = "CREATE TABLE "
				+ PUSH_BOX_TABLE_NAME
				+ " ("
				+ "_id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT,"
				+ " issolved INTEGER default 0, isdraft INTEGER default 0,type INTEGER,missionid INTEGER default 0,"
				+ " remoteid INTEGER default 0,resove_filename TEXT,map_filename TEXT,resolve_time TIMESTAMP,create_time TIMESTAMP,hasuploaded INTEGER default 0,uploaded_time TIMESTAMP)";
		db.execSQL(sql1);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS " + PUSH_BOX_TABLE_NAME);
	}

}
